﻿@model PagedList<LPY.LeHealth.Model.PhysicalPeople1>
@using Webdiyer.WebControls.Mvc;

@{
    ViewBag.Title = "ShowDetail";
    Layout = "~/Views/Shared/_HospitalAdminLayout.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ShowDetail</title>
    
    <script src="~/Scripts/layer-v2.4/layer/layer.js"></script>
    <script>

        function addOrder(obj, OrderId) {

          
            var DcomName = "";//定义套餐名称

            var ShopCount = "";//定义套餐数量

            var SumPrice = "";//定义套餐总价

            var PreferentialPrice = ""//定义优惠价格

            var CreateDate = "";//订单日期

            var BookerName = "";//预订人

            var BookerPhone = "";//预订人电话

            var PayState = "";//订单状态
            $.ajax({
                type: "get",
                url: "/Hospital/GetOrderById",
                data: { OrderId: OrderId },
                async: false,//同步刷新
                success: function (result) {
                    result = eval(result);
                    
                    if(result.length>0)
                    {
                        
                        for (var i = 0; i <result.length; i++) {

                            DcomName = result[i]["DcomName"];
                            ShopCount = result[i]["ShopCount"];
                            SumPrice = result[i]["SumPrice"];
                            PreferentialPrice = result[i]["PreferentialPrice"];
                            CreateDate = result[i]["CreateDate"];
                            BookerName = result[i]["BookerName"];
                            BookerPhone = result[i]["BookerPhone"];
                            if (result[i]["PayState"] == 0)
                            {
                                PayState = "待支付";
                            }
                            else if (result[i]["PayState"] == 1)
                            {
                                PayState = "待预约";
                            }
                            else if (result[i]["PayState"] == 2)
                            {
                                PayState = "待体检";
                            }
                            else
                            {
                                PayState = "体检完成";
                            }
                        }
                    }
                }
            })

            var strHtml = "<table>";
           
            strHtml += "<tr><td>套餐数量:</td><td>" + ShopCount + "</td></tr>";
            strHtml += "<tr><td>订单总价:</td><td>" + SumPrice + "</td></tr>";
            strHtml += "<tr><td>优惠价格：</td><td>" + PreferentialPrice + "</td></tr>";
            strHtml += "<tr><td>体检人电话:</td><td>" + BookerPhone + "</td></tr>";
            strHtml += "</table>";
            layer.open({
                type: 1,
                skin: "layui-layer-rim",
                title: "订单详情",
                area: ["280px", "200px"],
                content: strHtml
            })
        }

        function DelDetails(obj, orderid)
        {

            if(confirm('是否删除?'))
            {
                $.ajax({
                    type:"post",
                    url: "/Hospital/DelDetails",
                    data:{orderid:orderid},
                    success: function (data) {

                        if(data>0)
                        {
                            alert('删除成功!');
                            //$(obj).parent.parent.Remove();
                            location.href = "/Hospital/ShowDetail";
                        }
                        else

                        {
                            alert('删除失败!');
                        }
                    }
                })
            }

        }
        //全选事件
        function Select()
        {
            var cbid = document.getElementById("checkall").checked;
            var cbname = document.getElementsByName("checkid");
            for(var b in cbname)
            {

                cbname[b].checked=cbid;
            }
        }

        //批量审批
        function PlSp()
        {
            var chk_value = [];
            $('input[name="checkid"]:checked').each(function () {
                chk_value.push($(this).val());
            });
            if (chk_value.length == 0) {
               alert('请至少选择一项');
               return;
           }
           else
           {
               $.ajax({
                   type: "post",
                   url: "/Hospital/PUpdate",
                   data: { Orderid: chk_value.toString(), StateDemoId: $("#StateDemoId").val() },
                   success: function (data) {
                       if (data == 1) {
                           alert('批量审核成功！');
                           location.href="/Hospital/ShowDetail";
                       }
                       else {
                           alert('审核失败！,请选择订单状态');

                       }
                   }
               });
           }

        }



    </script>
</head>
<body>
    <div class="content">
        <div class="row">
            <div class="col-md-2">
                <div class="list-group">
                    @*<a href="#" class="list-group-item active">人员体检信息查看</a>*@
                </div>
            </div>
            <div class="col-md-10">
                <div class="page-header clearfix" style="padding:10px;">
                    <h4 class="pull-left">按订单状态及日期查询订单信息</h4>
                    <!--操作按钮-->
                    <div class="pull-right">

                    </div>
                </div>

                <!--内容区域-->
                
                <form id="user-search-form" class="form-inline well well-sm" action="/Hospital/SelectDetails" method="get" novalidate="">
                    <div class="form-group">
                        订单状态:@Html.DropDownList("StateDemoId") 订单编号:<input type="text" id="keyword" name="ExamName" class="form-control">预定日期:<input type="text" name="datetime1" class="form-control" />至<input type="text" name="datetime2" class="form-control" /><input type="submit" value="搜索" />
                    </div>
                </form>
                <div class="page-header clearfix" style="padding:10px;">
                    <h4 class="pull-left">按套餐类别查询订单信息</h4>
                    <!--操作按钮-->
                    <div class="pull-right">

                    </div>
                </div>
                <form class="form-inline well well-sm" novalidate="">
                    
                    <div class="form-group">
                        
                        @foreach (var combo in @ViewBag.Id)
                        {

                            <a href="/Hospital/ShowDetail/@combo.DcomId" style="text-decoration:none;width:120px;height:75px;font-size:larger">@combo.DcomName&nbsp;&nbsp;&nbsp;&nbsp;|</a>
                        }
                    </div>
                </form>

                <div class="form-group">
                   
                    订单状态:@Html.DropDownList("StateDemoId")
                    <input type="button" value="批量审批" onclick="PlSp()" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button" value="订单导出" onclick="window.location.href='/Hospital/SetFileDD'" />
                    @*@Html.ActionLink("体检信息导出", "SetFileDD", new {style="width:150px;height:75"})*@

                    @*<form id="user-search-form1" class="form-inline well well-sm" action="/Hospital/SelectDetails1" method="post" novalidate="">
                <div>
                    <input type="submit" value="搜索" />

                </div>
            </form>*@
                    <table id="user-table" class="table table-striped table-hover" data-search-form="#user-search-form">
                        <thead>
                            <tr>
                                <th><input type="checkbox" id="checkall" onclick="Select()" />全选</th>
                                <th>体检人</th>
                                <th>套餐名称</th>
                                <th>套餐价格</th>
                                <th>预约时间</th>
                                <th>订单状态</th>
                                <th>预约人</th>
                                <th>体检人身份证</th>
                                <th>操    作</th>
                            </tr>
                        </thead>
                        @foreach (var item in Model)
                        {

                            <tr>
                                <td><input type="checkbox" name="checkid" value="@item.OrderId" class="cd" /></td>
                                <td>@item.Name</td>
                                <td>@item.ComBomName</td>
                                <td>@item.ComPrice</td>
                                <td>@item.AppointmentTime</td>
                                <td>@item.State</td>
                                <td>@item.Yname</td>
                                <td>@item.SfAdd</td>
                                <td><a href="#" onclick="addOrder(this,@item.OrderId)">详细</a></td>
                                <td><a href="/Hospital/EditDetails/@item.OrderId" onclick="return confirm('是否要修改订单状态?')">订单状态修改</a></td>
                                @*<td><a href="/Hospital/DelDetails/@item.OrderId" onclick="return confirm('是否删除?')">删除</a></td>*@
                                @*<td><a href="#" onclick="DelDetails(this,@item.OrderId)">删除</a></td>*@
                            </tr>



                        }
                        <tbody id="mytbody"></tbody>
                    </table>

                    <!--分页-->
                    <nav class=" text-center">
                        @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "PageIndex" })
                    </nav>
                </div>
        </div>
    </div>
</body>
</html>
